/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.letmeshare.pedagogue.core.entities;

import java.io.Serializable;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.Id;
import org.letmeshare.pedagogue.core.validation.ValidationException;
import org.letmeshare.pedagogue.core.validation.Validator;

/**
 *
 * @author ibisuser1
 */
@Entity
public abstract class Party implements Serializable, Validator {
    private static final long serialVersionUID = 1L;
    @Id
    private String uid;
    
    @Embedded
    private Credentials credentials;

    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }

    public Credentials getCredentials() {
        return credentials;
    }

    public void setCredentials(Credentials credentials) {
        this.credentials = credentials;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (uid != null ? uid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the uid fields are not set
        if (!(object instanceof Party)) {
            return false;
        }
        Party other = (Party) object;
        if ((this.uid == null && other.uid != null) || (this.uid != null && !this.uid.equals(other.uid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.letmeshare.pedagogue.demographic.entities.Party[ id=" + uid + " ]";
    }

    @Override
    public void validate() throws ValidationException {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
}
